export default {
  promisePlus(self,msg,promise,successFn,faultFn,errorFn,finallyFn){
    self.loading = true;
    if (successFn != null){
      promise.then(successFn);
    } else {
      promise.then((res)=>{
        if (res.code == 0){
          self.$message({
            message: msg+'成功',
            type: 'success'
          });
        }
      })
    }
    if (faultFn != null){
      promise.then(faultFn);
    } else {
      promise.then((res)=>{
        if (res.code != 0){
          self.$message({
            message: msg + '失败 ' + res.message,
            type: 'warning'
          });
        }
      })
    }
    if (errorFn != null){
      promise.catch(errorFn);
    } else {
      promise.catch((e)=>{
        console.error(msg + '异常', e);
        self.$message({
          message: msg + '异常',
          type: 'error'
        });
      })
    }
    if (finallyFn != null){
      promise.finally(finallyFn);
    } else {
      promise.finally(() => {
        self.loading = false;
      });
    }
  },
}